package com.fare.taluo.core.domain.config.product;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Table;

import com.dayatang.domain.InstanceFactory;
import com.fare.taluo.base.ddd.domain.baseentity.BaseEntity;
@javax.persistence.Entity
@Table(name = "FDC_PRODUCT")
@SuppressWarnings("serial")
public class ProductEntity extends BaseEntity{

	@Column(name = "COMPANY_NAME")
	private String companyName;
	@Column(name = "NAME")
	private String name;
	@Column(name = "PRODUCT_TYPE")
	private String productType;
	@Column(name = "VOYAGE")
	private double voyage;
	@Column(name = "START_CITY")
	private String startCity;
	@Column(name = "END_CITY")
	private String endCity;
	@Column(name = "SPACE")
	private String space;
	@Column(name = "PRICE")
	private double price;
	@Column(name = "PRODUCTLINK")
	private String productLink;
	@Column(name = "TAGET_DATE")
	private String tagetDate;
	@Column(name = "TRAVEL_DATE")
	private String travelDate;
	
//	private static ProductEntityRepository repository = InstanceFactory.getInstance(ProductEntityRepository.class);
	 
	private static ProductEntityRepository getProductEntityRepository(){
		return InstanceFactory.getInstance(ProductEntityRepository.class);
	}
	
//	public static ProductEntityRepository  getRepository() {
//		if (repository == null) {
//			repository = InstanceFactory.getInstance(ProductEntityRepository.class);
//		}
//		return repository;
//	}
	
	public List<ProductEntity> findAll(){
		return getProductEntityRepository().findAll();
	};
	
	public List<ProductEntity> findProductByConditions(String name,String companyName,
			String startCity,String endCity,String productType){
		return getProductEntityRepository().findProductByConditions(name, companyName,startCity,endCity,
				productType);
	};
	
	public void saveOrUpdate(ProductEntity productEntity){
		getProductEntityRepository().saveOrUpdate(productEntity);
	};
	
	public void delete(ProductEntity productEntity){
		getProductEntityRepository().delete(productEntity);
	};
	
	public String getCompanyName() {
		return companyName;
	}
	public void setCompanyName(String companyName) {
		this.companyName = companyName;
	}
	public double getVoyage() {
		return voyage;
	}
	public void setVoyage(double voyage) {
		this.voyage = voyage;
	}
	public double getPrice() {
		return price;
	}
	public void setPrice(double price) {
		this.price = price;
	}
	public String getProductLink() {
		return productLink;
	}
	public void setProductLink(String productLink) {
		this.productLink = productLink;
	}
//	public Integer getId() {
//		return id;
//	}
//	public void setId(int id) {
//		this.id = id;
//	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}

	public String getTagetDate() {
		return tagetDate;
	}

	public void setTagetDate(String tagetDate) {
		this.tagetDate = tagetDate;
	}

	public String getTravelDate() {
		return travelDate;
	}

	public void setTravelDate(String travelDate) {
		this.travelDate = travelDate;
	}

	public String getProductType() {
		return productType;
	}

	public void setProductType(String productType) {
		this.productType = productType;
	}

	public String getStartCity() {
		return startCity;
	}

	public void setStartCity(String startCity) {
		this.startCity = startCity;
	}

	public String getEndCity() {
		return endCity;
	}

	public void setEndCity(String endCity) {
		this.endCity = endCity;
	}

	public String getSpace() {
		return space;
	}

	public void setSpace(String space) {
		this.space = space;
	}
}
